import React, { Component } from "react";
class Success extends Component {
  changbox = (index) => {
    return () => {
      this.props.onAddlisted(index);
    };
  };
  render() {
    return (
      <>
        <h2>已完成</h2>
        <ul className="listed">
          {/* 子组件直接通过this.props获取父组件传入的数据 */}
          {this.props.listed.map((item) => (
            <li key={item.id}>
              <input
                type="checkbox"
                checked="checked"
                onChange={this.changbox(item.id)}
              />
              <span>{item.list}</span>
            </li>
          ))}
        </ul>
      </>
    );
  }
}
export default Success;
